# Maintainer: Alexey Pavlov <alexpux@gmail.com>

pkgbase=libassuan
pkgname=('libassuan' 'libassuan-devel')
pkgver=2.5.1
pkgrel=1
pkgdesc="A IPC library used by some GnuPG related software"
arch=('i686' 'x86_64')
url="https://gnupg.org/related_software/libassuan"
license=('GPL')
makedepends=('libgpg-error-devel')
options=('strip' 'libtool')
source=(https://gnupg.org/ftp/gcrypt/${pkgname}/${pkgname}-${pkgver}.tar.bz2{,.sig}
        'msysize.patch')
sha256sums=('47f96c37b4f2aac289f0bc1bacfa8bd8b4b209a488d3d15e2229cb6cc9b26449'
            'SKIP'
            '8cb6df3a2c4554e42139219dc56ee98a193948b61f3974d80ea8f38faf7db665')

prepare() {
  cd "${pkgname}-${pkgver}"
  patch -Np1 -i "${srcdir}/msysize.patch"
  autoreconf -fi
}

build() {
  cd "${pkgname}-${pkgver}"
  ./configure \
    --prefix=/usr \
    --build=${CHOST} \
    --enable-shared \
    --enable-static

  make no_undefined="-no-undefined"
  make DESTDIR="${srcdir}/dest" install
}

check() {
  cd "${pkgname}-${pkgver}"
  #make check
}

package_libassuan() {
  groups=('libraries')
  depends=('gcc-libs' 'libgpg-error')
  install=libassuan.install

  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin/

  mkdir -p ${pkgdir}/usr/share
  cp -rf ${srcdir}/dest/usr/share/info ${pkgdir}/usr/share/

  install -D -m644 ${srcdir}/${pkgname}-${pkgver}/COPYING ${pkgdir}/usr/share/licenses/${pkgname}/COPYING
}

package_libassuan-devel() {
  pkgdesc="Libassuan headers and libraries"
  groups=('development')
  options=('staticlibs')
  depends=("libassuan=${pkgver}" 'libgpg-error-devel')

  mkdir -p ${pkgdir}/usr/bin
  cp -rf ${srcdir}/dest/usr/bin/libassuan-config ${pkgdir}/usr/bin/
  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/

  mkdir -p ${pkgdir}/usr/share
  cp -rf ${srcdir}/dest/usr/share/aclocal ${pkgdir}/usr/share/
}
